package com.naiterui.ehp.bp.security.utils.enums;

import java.util.Arrays;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum RequestMethodEnum {

  /**
   * 搜寻 @AnonymousGetMapping
   */
  GET("GET"),

  /**
   * 搜寻 @AnonymousPostMapping
   */
  POST("POST"),

  /**
   * 搜寻 @AnonymousPutMapping
   */
  PUT("PUT"),

  /**
   * 搜寻 @AnonymousPatchMapping
   */
  PATCH("PATCH"),

  /**
   * 搜寻 @AnonymousDeleteMapping
   */
  DELETE("DELETE"),

  /**
   * 否则就是所有 Request 接口都放行
   */
  ALL("All");

  /**
   * Request 类型
   */
  private final String type;

  public static RequestMethodEnum find(String type) {
    return Arrays.stream(RequestMethodEnum.values()).filter(value -> type.equals(value.getType()))
        .findFirst().orElse(ALL);
  }

}
